# 定义一个空列表用于存储学生信息
students = []

# 定义添加学生信息的函数
def add_student():
    name = input("请输入学生姓名: ")
    scores = []
    num_subjects = int(input("请输入课程数量: "))
    for i in range(num_subjects):
        score = float(input(f"请输入第 {i + 1} 门课程的成绩: "))
        scores.append(score)
    student = {
        "name": name,
        "scores": scores
    }
    students.append(student)
    print(f"{name} 的信息已添加。")

# 定义显示学生信息的函数
def display_students():
    if not students:
        print("目前没有学生信息。")
    else:
        for student in students:
            print(f"姓名: {student['name']}")
            print("成绩: ", end="")
            for score in student['scores']:
                print(score, end=" ")
            print()

# 定义计算学生平均成绩的函数
def calculate_average_scores():
    if not students:
        print("目前没有学生信息。")
    else:
        for student in students:
            if not student['scores']:
                print(f"{student['name']} 没有成绩记录。")
            else:
                average_score = sum(student['scores']) / len(student['scores'])
                print(f"{student['name']} 的平均成绩是: {average_score:.2f}")

# 主程序循环
while True:
    print("\n请选择操作:")
    print("1. 添加学生信息")
    print("2. 显示学生信息")
    print("3. 计算学生平均成绩")
    print("4. 退出")
    choice = input("请输入选项编号: ")

    if choice == '1':
        add_student()
    elif choice == '2':
        display_students()
    elif choice == '3':
        calculate_average_scores()
    elif choice == '4':
        print("程序已退出。")
        break
    else:
        print("无效的选项，请重新输入。")
